﻿Imports NHibernate
Imports FrameworkNHibernate.Dal

<Obsolete("Descontinuado.")> _
Public Class BaseNHibernateDao
    Implements IBaseDao

    Public Sub Alterar(ByRef entity As Object) Implements IBaseDao.Alterar
        CurrentSession.Update(entity)
    End Sub

    Public Sub Apagar(ByRef entity As Object) Implements IBaseDao.Apagar
        CurrentSession.Delete(entity)
    End Sub

    Public Function Buscar(ByVal tipo As System.Type, ByRef Id As Object) As Object Implements IBaseDao.Buscar
        Return CurrentSession.Load(tipo, Id)
    End Function

    Public Sub Salvar(ByRef entity As Object) Implements IBaseDao.Salvar
        CurrentSession.Save(entity)
    End Sub

    Public Sub SalvarOuAlterar(ByRef entity As Object) Implements IBaseDao.SalvarOuAlterar
        CurrentSession.SaveOrUpdate(entity)
    End Sub

    Private _sessionFactory As ISessionFactory
    Public Property SessionFactory() As ISessionFactory
        Get
            Return _sessionFactory
        End Get
        Set(ByVal value As ISessionFactory)
            _sessionFactory = value
        End Set
    End Property

    Protected ReadOnly Property CurrentSession() As ISession
        Get
            Return SessionFactory.GetCurrentSession()
        End Get
    End Property

End Class


